# -*- coding: utf-8 -*-
import os

def merge_file(path):
    try:
        os.chdir(path)
        cmd = "copy /b * new.tmp"
        os.system(cmd)
        os.system('del /Q *.ts')
        os.system('del /Q *.mp4')
        os.rename("new.tmp", "new.mp4")
        os.system("cd .> 1")
    except:
        print("merge path err at: " + path)



def listdir(path, list_name):  #传入存储的list
    for file in os.listdir(path):
        file_path = os.path.join(path, file)
        if os.path.isdir(file_path):
            done_path = file_path + "\\1"
            if not os.path.exists(done_path) and len(os.listdir(file_path)) > 0:
                list_name.append(file_path)




dir = []
listdir(os.path.abspath('.'), dir)
for i in dir:
    print(i)
    merge_file(i)

